package com.example.aircraftwar.codes.strategy;


import android.content.Context;

import com.example.aircraftwar.codes.aircraft.AbstractAircraft;
import com.example.aircraftwar.codes.bullet.BaseBullet;
import com.example.aircraftwar.codes.bullet.HeroBullet;

import java.util.LinkedList;
import java.util.List;

/**
 * 英雄机在常规状态下直射子弹的射击方式
 *
 */

public class HeroStraightShoot  implements ShootStrategy {
    private int shootNum = 1;
    private int power = 30;
    private int direction = -1;

    @Override
    public List<BaseBullet> executeShootStrategy(Context context, AbstractAircraft abstractAircraft) {
        List<BaseBullet> res = new LinkedList<>();
        int x = abstractAircraft.getLocationX();
        int y = abstractAircraft.getLocationY();
        int speedX = 0;
        int speedY = abstractAircraft.getSpeedY() + direction * 10;
        BaseBullet abstractBullet;
        for (int i = 0; i < shootNum; i++) {
            // 子弹发射位置相对飞机位置向前偏移
            // 多个子弹横向分散
            abstractBullet = new HeroBullet(context, x + (i * 2 - shootNum + 1) * 10, y - abstractAircraft.getImageHeight() / 2, speedX, speedY, power);
            res.add(abstractBullet);
        }
        return res;
    }

}
